package com.wisemoresystem.seal.base.action;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.ne.framework.data.page.Page;
import org.ne.framework.data.util.ChkTools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;

import com.wisemoresystem.seal.base.tip.Tip;
import com.wisemoresystem.seal.service.LogService;
import com.wisemoresystem.seal.service.ModelService;

public class ProjBaseAction {

	protected static Logger logger = Logger.getLogger(ProjBaseAction.class);

	@Autowired
	protected ModelService oc;
	@Autowired
	protected LogService logT;

	protected HttpServletRequest req;
	protected HttpServletResponse resp;

	// 操作结果提示与说明(例如:操作成功)
	public Tip tip = new Tip();

	private Map<String, Object> srh_params = new HashMap<String, Object>();
	public Map<String, Object> result = new HashMap<String, Object>();

	public Page page = new Page();

	// =============== params ========================
	public void putParam(String key, Object val) {
		if (ChkTools.isNull(key)) {
			return;
		}
		if (ChkTools.isNotNull(val)) {
			srh_params.put(key, val);
		} else {
			srh_params.remove(key);
		}
	}

	public void setSrh_params(Map<String, Object> srh_params) {
		if (srh_params != null && srh_params.size() > 0) {
			this.srh_params = srh_params;
		}
	}

	public Map<String, Object> getSrh_params() {
		return srh_params;
	}

	// ============= request and response ========================
	@ModelAttribute
	public void setReqAndResp(HttpServletRequest req, HttpServletResponse resp) {
		this.req = req;
		this.resp = resp;

	}

	// ========= get / set ()===================

	public void setTipMsg(String msg) {
		this.setTipMsg(msg, Tip.Type.info);
	}

	public void setTipMsg(String msg, Tip.Type type) {
		tip.setMsg(msg);
		tip.setType(type);
	}
}
